package com.woniu.config;

import com.woniu.interceptor.VisitStatisticsInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private VisitStatisticsInterceptor visitStatisticsInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(visitStatisticsInterceptor)
                .addPathPatterns("/**")          // 拦截所有接口
                .excludePathPatterns("/static/**"); // 排除静态资源
    }
}
